package proxy.jdk;

import proxy.Computer;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author ZhuQi
 * @ClassName RazerBookProxyHandel
 * @Date 2022/8/19 15:18
 * @Version 1.0
 * @Description TODO
 */
public class RazerBookProxyHandel implements InvocationHandler {

    private Object object;

    public RazerBookProxyHandel(Object computerProxy) {
        this.object = computerProxy;
    }

    /**
     * 代理方法
     * @param proxy 代理类
     * @param method 方法
     * @param args 参数
     * @return
     * @throws Throwable
     */
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("proxy before");
        Object result = method.invoke(object, args);
        System.out.println(result);
        System.out.println("proxy after");
        return result;
    }
}
